home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Delphi Magazine Collection 2001
/
Delphi Magazine Collection 20001 (2001).iso
/
DISKS
/
Issue62
/
ClassEng
/
Listing4.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
2000-09-01
|
792b
|
29 lines
Listing 4
TParent = class(TObject)
public
procedure DecideEarly;
procedure DecideLate; virtual;
end;
TChild = class(TParent)
public
procedure DecideEarly;
procedure DecideLate; override;
end;
...
Parent: TParent;
Child: TChild;
ParentalChild: TParent;
...
Parent := TParent.Create;
Child := TChild.Create;
ParentalChild := TChild.Create; // TChild assigned to TParent!
// early bound (non-virtual) calls
Parent.DecideEarly; // TParent version called
Child.DecideEarly; // TChild version called
ParentalChild.DecideEarly; // TParent version called
// late bound (virtual) calls
Parent.DecideLate; // TParent version called
Child.DecideLate; // TChild version called
ParentalChild.DecideLate; // TChild version called